// pages/servemap/servemap.js
import {ServicePoint} from "../../http/myinfo.js"
import {getMap} from '../../http/interface.js'

Page({

    /**
     * 页面的初始数据
     */
    data: {
        service_name: '',
        banner: [],
        indicatorDots: false,
        vertical: false,
        autoplay: false,
        interval: 2000,
        duration: 500,
        currentIndex: 0,
        points: [],
        serviceS:[],
        scale:0,
    },
    getMapList() {
        getMap(0).then(res => {
            if (res.status == 1) {
                var banner = res.data;
                for (var i in banner) {
                    banner[i].scale = 750 / banner[i].width
                }
                this.setData({
                    banner: res.data,
                    scale:750 / banner[i].width
                })
                
            }
        })
    },
    swiperChange: function (e) {
        console.loe(e.detail.current)
        this.setData({
            currentIndex: e.detail.current,
            serviceS: this.data.points[ e.detail.current].service
        })
    },
    ServicePoint() {
        var _ = this;
        ServicePoint(this.data.service_name).then(res => {
            console.log(res)
            if (res.status == 1) {
                var points = res.data;
                for (var i in points) {
                    points[i].scale = 750 / points[i].width
                }
                console.log(750 / points[i].width);
                _.setData({
                    points: points,
                    serviceS: res.data[this.data.currentIndex].service
                })
                
            }
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        if (options.service_name) {
            this.setData({
                service_name: options.service_name
            });
            wx.setNavigationBarTitle({
                title: '服务设施 >' + options.service_name
            });
           
        }
        this.ServicePoint();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})